import os
import sys
from PyQt4 import QtGui, QtCore

if os.getcwd() == os.path.split(sys.argv[0])[0]:
    os.chdir('..\\')
    sys.path.append(os.getcwd())
    #print sys.path
else:
    sys.path.append(os.path.split(sys.argv[0])[0])
    mypath = os.path.split(os.path.split(sys.argv[0])[0])
    sys.path.append(mypath[0])

import library


class QuitButton(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.setGeometry(300, 300, 300, 400)
        self.setWindowTitle('Quit button')

        self.bquit = QtGui.QPushButton('Close', self)
        self.bquit.setGeometry(230, 350, 60, 35)
        
        self.lineA = QtGui.QLineEdit(self)
        self.lineA.setGeometry(150, 10, 100, 20)
        
        self.lineLA = QtGui.QLabel(self)
        self.lineLA.setText("Username")
        self.lineLA.setGeometry(10, 10, 100, 20)
        
        self.lineB = QtGui.QLineEdit(self)
        self.lineB.setGeometry(150, 40, 100, 20)
        
        self.lineLB = QtGui.QLabel(self)
        self.lineLB.setText("Password")
        self.lineLB.setGeometry(10, 40, 100, 20)
        
        self.bok = QtGui.QPushButton('OK', self)
        self.bok.setGeometry(200, 80, 60, 35)
        self.connect(self.bok, QtCore.SIGNAL("clicked()"), self.inputdata)

        self.connect(self.bquit, QtCore.SIGNAL('clicked()'),
            QtGui.qApp, QtCore.SLOT('quit()'))
        #self.connect(self.bquit, QtCore.SIGNAL("clicked()"), self.gettext)


    
    def inputdata(self):
        settime = library.l_time()
        datatime = settime.gettime()
        temp_login = library.temp_ver(2,str(self.lineA.text()), str(self.lineB.text()),"1", str(datatime))
        temp_login.insertdata()
        print temp_login.verify()


app = QtGui.QApplication(sys.argv)
qb = QuitButton()
qb.show()
sys.exit(app.exec_())